package com.example.library;

import android.content.Context;

import com.example.library.http.ApiMethods;
import com.example.library.http.KnowledgeParseEntity;
import com.example.library.http.MyObserver;
import com.example.library.http.ObserverOnNextListener;

/**
 * Created by dadong on 2018/8/18.
 * Describe:
 */
public class RequestKnowledgeParseEntity {

    Context context;
    RequestBack requestBack;

    public RequestKnowledgeParseEntity(Context context, RequestBack requestBack) {
        this.context = context;
        this.requestBack = requestBack;
    }

    KnowledgeParseEntity entity = new KnowledgeParseEntity();

    public void getData(final String knowledge, String leveCode, String schoolId, String stageNo, String stuId) {

        ObserverOnNextListener<KnowledgeParseEntity> listener = new ObserverOnNextListener<KnowledgeParseEntity>() {
            @Override
            public void onNext(KnowledgeParseEntity knowledgeEntity) {
                if (knowledgeEntity != null) {
                    //   Logger.d("shishisaonian " + knowledgeEntity.getCwName());
                    entity = knowledgeEntity;
                    requestBack.onSuccess(knowledgeEntity);
                }
            }

            @Override
            public void onErr(Throwable e) {
                requestBack.onErr(e);
                // Logger.d("shishisaonian" + e.getMessage());
            }
        };
        ApiMethods.getKnowledgeParse(new MyObserver<KnowledgeParseEntity>(context, listener), knowledge, leveCode, schoolId, stageNo, stuId);
    }

}
